Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ADD] crm_lead_substage: Substages for leads/opportunities #74

Closed
wants to merge 1 commit into from

Conversation

pedrobaeza
Copy link
Member

Substages for leads/opportunities

This module allows to set substages inside the same stage for fine-graining
the reasons or flows on the CRM pipelines.

Configuration

Go to Sales > Configuration > Leads & Opportunities > Substages for defining
the substages you want and set the stages where this substages are going to be
available

Usage

Go to Sales > Leads or Sales > Opportunities, and when you are in one stage,
the available substages are shown below. Click on one of them to set it. If you
change the stage, then the substage is reset and the new ones available for
this stage are shown.

@pedrobaeza
Copy link
Member Author

@rafaelbn, please check

@pedrobaeza pedrobaeza force-pushed the 8.0-crm_lead_substate branch from 3a13c66 to acbf9f5 Compare February 1, 2016 13:53
@rafaelbn
Copy link
Member

rafaelbn commented Feb 1, 2016

Maybe is not a problem of this module. Stages are not working, I cannot change stages in opportunities.

01-02-2016 17-25-22

@andhit-r
Copy link
Member

andhit-r commented Feb 2, 2016

@pedrobaeza I tried to install it on my local. Installation failed with log below:

File "/home/andhit_r/odoo8/oca_crm/crm_lead_substage/report/crm_lead_report.py", line 24, in init
cr.execute("CREATE OR REPLACE VIEW crm_lead_report AS (%s)" % view_def)
File "/home/andhit_r/odoo8/odoo/openerp/sql_db.py", line 158, in wrapper
return f(self, _args, *_kwargs)
File "/home/andhit_r/odoo8/odoo/openerp/sql_db.py", line 234, in execute
res = self.obj.execute(query, params)
ProgrammingError: syntax error at or near "."
LINE 1: ... REPLACE VIEW crm_lead_report AS ( SELECT c.i c.substage
...

I then raise your view_def variable. It showed:

SELECT c.i c.substage_id,
d, c.date_deadline, count(c.id) AS nbr_cases, c.date_open AS opening_date, c.date_closed, c.date_last_stage_update, c.user_id, c.probability, c.stage_id, c.type, c.company_id, c.priority, c.section_id, c.campaign_id, c.source_id, c.medium_id, c.partner_id, c.country_id, c.planned_revenue, c.planned_revenue * (c.probability / 100::double precision) AS probable_revenue, c.create_date, date_part('epoch'::text, c.date_closed - c.create_date) / (3600 * 24)::double precision AS delay_close, abs(date_part('epoch'::text, c.date_deadline::timestamp without time zone - c.date_closed) / (3600 * 24)::double precision) AS delay_expected, date_part('epoch'::text, c.date_open - c.create_date) / (3600 * 24)::double precision AS delay_open
FROM crm_lead c
WHERE c.active = true
GROUP BY c.id

I think You miss a comma (,) after c.id

@andhit-r
Copy link
Member

andhit-r commented Feb 2, 2016

Same error showed on travis

@pedrobaeza
Copy link
Member Author

I think it's because another module in this repo also overwrites the lead report without respecting inheritance chain (it's not easy in this case though).

@andhit-r
Copy link
Member

andhit-r commented Feb 2, 2016

This module only depend crm. I tested on fresh DB with demo data. I installed only this module after DB creation. No other module in this repo installed.

@pedrobaeza
Copy link
Member Author

Here it's the trick I use to insert the field: https://github.com/OCA/crm/pull/74/files#diff-9f5df14bda3a6d61aac3b7c881180811R16

Maybe this is not the same in your Odoo revision?

@andhit-r
Copy link
Member

andhit-r commented Feb 2, 2016

@pedrobaeza I'm using Odoo a688bcd and crm repo from your fork (8.0-crm_lead_substate) acbf9f5 .

I can not install crm_lead_substate due error i mentioned previously

@andhit-r
Copy link
Member

andhit-r commented Feb 2, 2016

@pedrobaeza are you going to insert substage_id or replace stage_id with substage_id on crm.lead.report?

@pedrobaeza
Copy link
Member Author

I'm inserting it, but the lack of inheritable methods for select, from and where parts make me do it that way to also allow another inheritances into account.

cr.execute("SELECT pg_get_viewdef('crm_lead_report', true)")
view_def = cr.fetchone()[0]
# Inject the new field in the expected SQL
sql = "c.stage_id,\n"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Try to change into sql = "c.stage_id,"

=================================
Substages for leads/opportunities
=================================

This module allows to set substages inside the same stage for fine-graining
the reasons or flows on the CRM pipelines.

Configuration
=============

Go to Sales > Configuration > Leads & Opportunities > Substages for defining
the substages you want and set the stages where this substages are going to be
available

Usage
=====

Go to Sales > Leads or Sales > Opportunities, and when you are in one stage,
the available substages are shown below. Click on one of them to set it. If you
change the stage, then the substage is reset and the new ones available for
this stage are shown.
@pedrobaeza pedrobaeza force-pushed the 8.0-crm_lead_substate branch from acbf9f5 to c55d694 Compare February 3, 2016 13:36
@pedrobaeza
Copy link
Member Author

I have used another part of the sentence that is going to be for sure (the SELECT part), so now it's working. Runbot red status is because a warning.

Thanks for your reviews.

@andhit-r
Copy link
Member

andhit-r commented Feb 3, 2016

Tested on runbot 👍

@api.multi
def onchange_stage_id(self, stage_id):
res = super(CrmLead, self).onchange_stage_id(stage_id)
res['value'] = res.get('value', {})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

res.setdefault() seems cleaner.

@dreispt
Copy link
Member

dreispt commented Feb 6, 2016

I worry about the functional rationale for this feature - could it be adding avoidable complexity?
I would like to see, in the README, an example use case where additional Stages are clearly not enough.


Go to Sales > Configuration > Leads & Opportunities > Substages for defining
the substages you want and set the stages where this substages are going to be
available

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

period

@elicoidal
Copy link

Like @dreispt I am not sure about the rationale here but it is not a real blocking point

@pedrobaeza
Copy link
Member Author

We will rethink this now and come back here. I close for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants